Repository navigation
fix: stop XHR retries once the request is aborted - #470
igoroctaviano wants to merge 1 commit into
Conversation
dicomweb-client passes the request's AbortSignal to request hooks as `metadata.signal` when the `request.signal` option is used. The retry hook now honors it: an aborted request is not sent, a scheduled retry is cancelled instead of re-opening and re-sending the request, and a retryable response that arrives after the abort is passed on rather than retried. Without a signal the hook behaves as before. This keeps cancelled tile requests (e.g. Viv tiles pruned while panning) from being downloaded again after a 429/5xx.
|
|
|
Overall Grade |
Security Reliability Complexity Hygiene |
Code Review Summary
| Analyzer | Status | Updated (UTC) | Details |
|---|---|---|---|
| JavaScript | Nov 3, 2026 10:07p.m. | Review ↗ |
Important
AI Review is run only on demand for your team. We're only showing results of static analysis review right now. To trigger AI Review, comment @deepsourcebot review on this thread.
📦 Firebase Preview - Using Published DMVThis preview is using the published
|
|
Visit the preview URL for this PR (updated for commit a05a5a8): https://idc-external-006--pr470-fix-xhr-retry-stop-o-mm1n59ff.web.app (expires Tue, 10 Nov 2026 22:11:47 GMT) 🔥 via Firebase Hosting GitHub Action 🌎 Sign: 88aacecd98ba54d2f9c8d201a9444e43d1ad8307 |



Why
getXHRRetryHookschedules a re-send after a retryable status (429/500/502/503/504). If the caller cancels the request while a retry is waiting, the timer still fires: it callsrequest.open()andsend()again and downloads data nobody needs. This matters for tile loading, where Viv/deck.gl aborts tiles that scroll out of view while panning. The hook had no way to know about the abort.Related: ImagingDataCommons/dicom-microscopy-viewer#312 and ImagingDataCommons/dicom-microscopy-viewer#313 (headless tile reader with AbortSignal support).
What
dicomweb-client is getting a
request.signaloption. When it is set, request hooks receive the signal asmetadata.signal. The retry hook now honors that signal:operation.stop()), so there's no re-open and no re-send;Without a signal, the hook behaves exactly as before.
signal?: AbortSignalis added toDICOMwebClientRequestHookMetadatainAppConfig.d.ts.Merging is safe on its own. It takes effect once the dicomweb-client version with
request.signalis released and Slim uses it (dcmjs-org/dicomweb-client#144). With today's dicomweb-client,metadata.signalis never set, so nothing changes.Testing
The existing 7 tests in
src/utils/__tests__/xhrRetryHook.test.tsare unchanged and passing.4 new tests cover:
All 4 fail against the previous hook.
Full suite: 177 passed.
tsc --noEmitand biome are clean.